<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';

if($_RQ['op']=='list'){
	$return['list']=pdo_fetchall('SELECT mid,SUM(price),count(1) FROM '.tablename('jy_weishop_order').' WHERE ispay=1 and uniacid= '.$_SESSION['uniacid'].' group by mid');
	paixu($return['list'],'SUM(price)','desc');
	foreach($return['list'] as $k=>&$v){
		$member=pdo_get('core_members',array('id'=>$v['mid']),array('nickname','mobile'));
		$v['nickname']=$member['nickname'];
		$v['mobile']=$member['mobile'];
		$v['rank']=$k+1;
		$v['total']=$v['count(1)'];
		$v['totalprice']=$v['SUM(price)'];
	}
	//print_r($return['list']);exit();
	$total=sizeof($return['list']);
	$totalpage=ceil($total/10);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =max(1, intval($_RQ['page']));;
	$htmls=array(
		'type'=>'list',
		
		'list'=>array('data'=>'list','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'rank','title'=>'排行','type'=>'string'),
			array('name'=>'nickname','title'=>'会员昵称','type'=>'string'),
			array('name'=>'mobile','title'=>'手机号','type'=>'string'),			
			array('name'=>'totalprice','title'=>'消费金额','type'=>'string'),
			array('name'=>'total','title'=>'订单数','type'=>'string'),
			
		)),
	
	);

	$return['htmls']=$htmls;
	
	exi($return);
}
